#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 110;
int f[N];
int x[N];
int w[N];
int v[N];
int n, t;
int main()
{
    cin >> n >> t;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i] >> w[i] >> v[i];
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = t; j >= 0; j--)
        {
            for (int k = 0; k <= x[i] && k * w[i] <= j; k++)
            {
                f[j] = max(f[j], f[j - k * w[i]] + k * v[i]);
            }
        }
    }
    cout << f[t] << endl;
    return 0;
}